<?php

class DatabaseSeeder extends Seeder {

    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run() {
        Eloquent::unguard();

        $this->call('UsersSeeder');
        $this->call('RecipesSeeder');
        $this->call('RecipesStepsSeeder');
        $this->call('RecipesCommentsSeeder');
        $this->call('RecipesLikesDislikesSeeder');
        $this->call('CommentsLikesDislikesSeeder');
    }

}

class UsersSeeder extends Seeder {

    public function run() {
        DB::table('users')->delete();

        User::create(
                array(
                    'id' => '1',
                    'user_name' => 'alex29',
                    'email' => 'alex@recetas.com',
                    'password' => Hash::make('alexalex'),
                    'name' => 'Alex',
                    'surname' => 'Fernandez',
                    'city' => 'Eurocity',
                    'country' => 'Spain',
                    'biography' => 'Mi vida y la cocina...'
                )
        );

        User::create(
                array(
                    'id' => '2',
                    'user_name' => 'tamara',
                    'email' => 'tamara@recetas.com',
                    'password' => Hash::make('tamtam123'),
                    'name' => 'Tamara',
                    'surname' => 'Osona',
                    'city' => 'Madriz',
                    'country' => 'Spain',
                    'biography' => 'Mi vida, la cocina y otras historias...'
                )
        );

        $this->command->info('Users table seeded');
    }

}

class RecipesSeeder extends Seeder {

    public function run() {
        DB::table('recipes')->delete();

        Recipe::create(
                array(
                	'id' => '1',
                    'name' => 'Receta 1',
                    'difficulty' => 'E',
                    'number_persons' => '2',
                    'calories' => '150',
                    'preparation_time' => '15',
                    'cooking_time' => '60',
                    'description' => 'Esta es la descripcion de mi receta 1',
                    'image_url' => 'img/recipes/receta1.png',
                    'user_id' => 1
                )
        );

        Recipe::create(
                array(
                	'id' => '2',
                    'name' => 'Receta 2',
                    'difficulty' => 'H',
                    'number_persons' => '4',
                    'calories' => '450',
                    'preparation_time' => '5',
                    'cooking_time' => '25',
                    'description' => 'Esta es la descripcion de mi receta 2',
                    'image_url' => 'img/recipes/receta2.png',
                    'user_id' => 2
                )
        );
        
        $this->command->info('Recipes table seeded');
    }

}

class RecipesStepsSeeder extends Seeder {

	public function run() {
		DB::table('recipes_steps')->delete();
		
		RecipesSteps::create(
		array(
		'recipe_id' => '1',
		'step_number' => '1',
		'step_description' => 'Descripcion paso 1',
		'title' => 'Titulo paso 1',
		'tip' => 'Consejo extra'
		)
		);

		RecipesSteps::create(
		array(
		'recipe_id' => '1',
		'step_number' => '2',
		'step_description' => 'Descripcion paso 2',
		'title' => 'Titulo paso 2',
		'tip' => 'Consejo extra'
		)
		);

		RecipesSteps::create(
		array(
		'recipe_id' => '1',
		'step_number' => '3',
		'step_description' => 'Descripcion paso 3',
		'title' => 'Titulo paso 3',
		'tip' => 'Consejo extra'
				)
		);
		
		RecipesSteps::create(
		array(
		'recipe_id' => '1',
		'step_number' => '4',
		'step_description' => 'Descripcion paso 4',
		'title' => 'Titulo paso 4',
		'tip' => 'Consejo extra'
				)
		);
		
		RecipesSteps::create(
		array(
		'recipe_id' => '1',
		'step_number' => '5',
		'step_description' => 'Descripcion paso 5',
		'title' => 'Titulo paso 5',
		'tip' => 'Consejo extra'
				)
		);
		
		$this->command->info('Recipes steps table seeded');
	}

}

class RecipesCommentsSeeder extends Seeder {

	public function run() {
		DB::table('recipes_comments')->delete();

		RecipesComments::create(
			array(
				'id' => '1',
				'comment' => 'Comentario 1',
				'user_id' => 1,
				'recipe_id' => '1',
				'parent_comment' => NULL,
			)
		);

		RecipesComments::create(
			array(
				'id' => '3',
				'comment' => 'Comentario 3',
				'user_id' => 1,
				'recipe_id' => '1',
				'parent_comment' => NULL,
			)
		);


		RecipesComments::create(
			array(
				'id' => '4',
				'comment' => 'Comentario 4',
				'user_id' => 1,
				'recipe_id' => '1',
				'parent_comment' => NULL,
			)
		);

		RecipesComments::create(
			array(
				'id' => '5',
				'comment' => 'Comentario 5',
				'user_id' => 1,
				'recipe_id' => '1',
				'parent_comment' => NULL,
			)
		);
		
		RecipesComments::create(
			array(
				'id' => '6',
				'comment' => 'Comentario 6',
				'user_id' => 1,
				'recipe_id' => '1',
				'parent_comment' => NULL,
			)
		);
		
		RecipesComments::create(
		array(
		'id' => '7',
		'comment' => 'Respuesta 1',
		'user_id' => 1,
		'recipe_id' => '1',
		'parent_comment' => 1,
		)
		);
		
		RecipesComments::create(
		array(
		'id' => '8',
		'comment' => 'Respuesta 2',
		'user_id' => 1,
		'recipe_id' => '1',
		'parent_comment' => 1,
		)
		);
		
		RecipesComments::create(
		array(
		'id' => '9',
		'comment' => 'Respuesta 3',
		'user_id' => 1,
		'recipe_id' => '1',
		'parent_comment' => 1,
		)
		);
		
		RecipesComments::create(
		array(
		'id' => '10',
		'comment' => 'Respuesta 4',
		'user_id' => 1,
		'recipe_id' => '1',
		'parent_comment' => 1,
		)
		);
		$this->command->info('Recipes table seeded');
	}

}

class RecipesLikesDislikesSeeder extends Seeder {

	public function run() {
		DB::table('recipes_likes_dislikes')->delete();

		RecipesLikesDislikes::create(
			array(
				'user_id' => '1',
				'recipe_id' => '1',
				'like' => 0
			)
		);

		RecipesLikesDislikes::create(
			array(
				'user_id' => '2',
				'recipe_id' => '1',
				'like' => 1
			)
		);

		RecipesLikesDislikes::create(
			array(
				'user_id' => '1',
				'recipe_id' => '2',
				'like' => 1
			)
		);
		
		RecipesLikesDislikes::create(
			array(
				'user_id' => '2',
				'recipe_id' => '2',
				'like' => 1
			)
		);
		
		$this->command->info('Recipes likes dislikes table seeded');
	}

}

class CommentsLikesDislikesSeeder extends Seeder {

	public function run() {
		DB::table('comments_likes_dislikes')->delete();

		CommentsLikesDislikes::create(
		array(
		'user_id' => '1',
		'recipe_id' => '1',
		'comment_id' => '1',
		'like' => 1
		)
		);

		CommentsLikesDislikes::create(
		array(
		'user_id' => '2',
		'recipe_id' => '1',
		'comment_id' => '1',
		'like' => 1
		)
		);

		CommentsLikesDislikes::create(
		array(
		'user_id' => '1',
		'recipe_id' => '1',
		'comment_id' => '2',
		'like' => 1
		)
		);

		CommentsLikesDislikes::create(
		array(
		'user_id' => '2',
		'recipe_id' => '1',
		'comment_id' => '2',
		'like' => 0
		)
		);

		$this->command->info('Comments likes dislikes table seeded');
	}

}